#ifndef HASHTABLE_H_
#define HASHTABLE_H_

#include <iostream>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

struct HashEntry {
  const char* key;
  int word_id;
  int df;
  HashEntry* next;
};

class HashTable {

public:
  explicit HashTable(int size);
  ~HashTable();

  int insert(const char* key, int& word_id);
  int get_id(const char* key) const;
  //int get_df(const char* key) const;
  int save(const std::string& file) const;

  void stat() const;
  void show() const;

private:

  unsigned int hash_fun(const char* key) const;
  int buckets_size_;
  HashEntry** table_;
  int entry_num_;     //HashEntry sum
  int used_buckets_;

};

#endif
